<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子32-ES6/7常用语法介绍</title>
    </head>

    <body>
        <pre>
            <code>
                // 例子32

                // 浅拷贝
                const target = {};
                const source = {
                    a: {
                        b: 1
                    },
                    c: 'c'
                }
                Object.assign(target, source);
                source.c = 'x';
                source.a.b = 2;
                console.log(target); // {a: {b: 2}, c: 'c'}

                //--------------------------------------------------------------------------

                // 数组的处理
                Object.assign([1, 2, 3], [4, 5]); // [4, 5, 3]

                //--------------------------------------------------------------------------

                // 取值函数的处理
                const source = {
                    get foo() {
                        return 1;
                    }
                }
                const target = {};
                Object.assign(target, source); // {foo: 1}
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/32.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>